#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif

#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define ssz(x) (signed((x).size()))
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k)                                                       \
  for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + (c - '0'); c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
constexpr ll MAXN = 1e5 + 5;
int n, rt, A, B, dfn[MAXN], seq[17][MAXN], sz[MAXN], fa[MAXN], dep[MAXN],
    /*  minv[MAXN], */ cnt = 0;
// bool ed[MAXN];
pii f[MAXN], g[MAXN], h[MAXN], w[MAXN];
vector<int> T[MAXN];
void dfs1(int x, int pre) {
  fa[x] = pre, dep[x] = dep[pre] + 1;
  sz[x] = 1, seq[0][dfn[x] = ++cnt] = x;
  // minv[x] = 1e9 + 5;
  // for (int i = 1, p = fa[x]; i <= B && p; i++, p = fa[p])
  //   cmin(minv[x], p);
  for (int v : T[x]) {
    T[v].erase(find(T[v].begin(), T[v].end(), x));
    dfs1(v, x), sz[x] += sz[v];
  }
}
int LCA(int x, int y) {
  if (x == y)
    return x;
  const auto [l, r] = minmax(dfn[x], dfn[y]);
  int f = 31 ^ __builtin_clz(r - l), u = seq[f][l + 1],
      v = seq[f][r - (1 << f) + 1];
  return fa[(dep[u] < dep[v]) ? u : v];
}
// int dist(int x, int y) { return dep[x] + dep[y] - dep[LCA(x, y)] * 2; }
// bool ok(int x, int y) {
//   int lca = LCA(x, y);
//   return lca != y && dep[x] + dep[y] - 2 * dep[lca] <= B;
// }
void dfs2(int x) {
  for (int v : T[x])
    dfs2(v);
  bool flg = 0;
  int p = -1;
  f[x] = g[x] = {}, w[x] = {1e9 + 5, 0}, h[x] = {x, x};
  vector<pii> v1, v2;
  For(i, dfn[x] + 1, dfn[x] + sz[x] - 1) {
    int y = seq[0][i];
    if (p + 1 < ssz(T[x]) && y == T[x][p + 1])
      p++, v1.eb(0, T[x][p]), v2.eb(1e9 + 5, T[x][p]);
    if (dep[y] == dep[x] + A) {
      flg = 1;
      int cur = 1e9 + 5;
      For(j, 1, n) {
        int lca = LCA(y, j), d = dep[y] + dep[j] - 2 * dep[lca];
        if (d > B)
          continue;
        if (lca != j)
          cmin(cur, f[j].fi);
        else {
          if (f[j].se == j || LCA(f[j].se, y) != f[j].se) {
            cmin(cur, f[j].fi);
            // if (x == 4 && y == 9 && j == 1)
            //   cerr << "! " << f[j].fi << '\n';
          } else if (g[j].se)
            cmin(cur, g[j].fi);
          else if (h[j].se == j || LCA(h[j].se, y) != h[j].se)
            cmin(cur, h[j].fi);
          else
            assert(w[j].se), cmin(cur, w[j].fi);
        }
      }
      cmax(v1.back().fi, cur);
    }
    if (dep[y] <= dep[x] + B) {
      cmin(v2.back().fi, y);
      // cerr << x << ' ' << y << ' ' << h[x].fi << ' ' << nxt.fi << '\n';
    }
  }
  for (pii nxt : v1)
    if (nxt.fi) {
      if (nxt >= f[x])
        g[x] = f[x], f[x] = nxt;
      else
        cmax(g[x], nxt);
    }
  for (pii nxt : v2)
    if (nxt.fi != int(1e9 + 5)) {
      if (nxt <= h[x])
        w[x] = h[x], h[x] = nxt;
      else
        cmin(w[x], nxt);
    }
  if (!flg) {
    f[x] = h[x], g[x] = w[x];
  }
  // cerr << "ok " << x << ' ' << f[x].fi << ' ' << f[x].se << ' ' << g[x].fi
  //      << ' ' << g[x].se << '\n';
}
namespace Sol1 {
int f[MAXN], g[MAXN], pre[MAXN];
void solve() {
  dfs1(rt, 0);
  deque<pii> dq;
  For(i, 1, n) {
    while (!dq.empty() && dq.front().se < i - B)
      dq.pop_front();
    pre[i] = dq.empty() ? int(1e9 + 5) : dq.front().fi;
    while (!dq.empty() && dq.back().fi > seq[0][i])
      dq.pop_back();
    dq.eb(seq[0][i], i);
    // cerr << pre[i] << " \n"[i == n];
  }
  dq.clear();
  deque<pii> dq2;
  ForDown(i, n, 1) {
    while (!dq.empty() && dq.front().se > i + B)
      dq.pop_front();
    while (!dq2.empty() && dq2.front().se > i + B)
      dq2.pop_front();
    while (!dq2.empty() && dq2.back().fi > seq[0][i])
      dq2.pop_back();
    dq2.eb(seq[0][i], i);
    if (i + A <= n)
      f[i] = g[i + A];
    else
      f[i] = dq2.front().fi;
    while (!dq.empty() && dq.back().fi > f[i])
      dq.pop_back();
    dq.eb(f[i], i);
    g[i] = min(pre[i], dq.front().fi);
    // cerr << i << ' ' << f[i] << '\n';
  }
  cout << f[1] << '\n';
}
} // namespace Sol1
void Main() {
  FileIO("nim");
  read(n, rt, A, B);
  For(i, 1, n - 1) {
    int u, v;
    read(u, v), T[u].eb(v), T[v].eb(u);
  }
  if (A <= B)
    return puts("1"), void();
  bool flg = 1;
  For(i, 1, n) flg &= ssz(T[i]) <= 2;
  if (flg)
    return Sol1::solve();
  /* minv[0] = 1e9 + 5, */ dfs1(rt, 0);
  For(i, 1, 16) For(j, 1, n - (1 << i) + 1) {
    int u = seq[i - 1][j], v = seq[i - 1][j + (1 << (i - 1))];
    seq[i][j] = dep[u] < dep[v] ? u : v;
  }
  dfs2(rt);
  cout << f[rt].fi << '\n';
}
} // namespace

signed main() { return Main(), 0; }
